package NP;

//
//  PblBinPack.java
//  
//
//  Created by tison on 09/11/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

public class PblPartition extends NPRed {
	private int n;
	private int[] tab;

	public PblPartition(int n, int ent[]) {
		// on initialise n et le tab ac les paramètres
		this.n = n;
		this.tab = ent;
	}

	public PbBinPack redPolyTo() {// transforme l’objet -instance de
									// Partition- en une instance "équivalente"
									// de PblBinPack:
		int somme = 0;
		for (int i = 0; i < n; i++) {
			somme += tab[i];
		}
		int valSac = somme / 2;
		int[] returnTab = { valSac, valSac };// new int[2];

		return new PbBinPack(n, tab, 2, returnTab);
	}

}
